package bupt.party.online.service.impl;

import java.util.List;
import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;

import bupt.party.online.dao.IAdminDao;
import bupt.party.online.model.Admin;
import bupt.party.online.model.Student;
import bupt.party.online.service.IAdminService;

public class AdminServiceImpl implements IAdminService {
	private IAdminDao adminDao;
	

	public IAdminDao getAdminDao() {
		return adminDao;
	}

	public void setAdminDao(IAdminDao adminDao) {
		this.adminDao = adminDao;
	}

	public Admin findAdminByUserIdAndPassword(String userId, String password) {
		
		return adminDao.findAdminByUserIdAndPassword(userId, password);
	}

	@Override
	public boolean saveOrUpdateAdmin(Admin admin) {
		
		return adminDao.saveOrUpdateAdmin(admin);
	}

	@Override
	public String findAdminNameByAdminNO(String adminNO) {
		return adminDao.findAdminNameByAdminNO(adminNO);
	}

	@Override
	public Admin findAdminByAmdinNO(String adminNO) {
		
		return adminDao.findAdminByAdminNO(adminNO);
	}

	@Override
	public boolean savePasswordByAdminNO(String adminNO, String password) {
		Admin  admin  =  adminDao.findAdminByAdminNO(adminNO);
		admin.setAdminPassword(password);
		
		return adminDao.saveOrUpdateAdmin(admin);
	}

	@Override
	public Admin findAdminByAdminNOAndBranchIds(String adminNO,
			Set<Integer> branch_ids) {
		
		return adminDao.findAdminByAdminNOAndBranchIds(adminNO, branch_ids);
	}

	@Override
	public DetachedCriteria getDetachedCriteria(Integer highLevelQuery,
			String queryContent, Integer firstpa, Integer secondpa,String adminNO) {
		
		return adminDao.getDetachedCriteria(highLevelQuery, queryContent, firstpa, secondpa,adminNO);
	}

	@Override
	public int queryAdminCountWithCriteria(DetachedCriteria detachedCriteria) {
		
		return adminDao.queryAdminCountWithCriteria(detachedCriteria);
	}

	@Override
	public List<Admin> queryAdminWithCriteria(
			DetachedCriteria detachedCriteria, int pageNow, int pageSize) {
		int firstResult = (pageNow-1)*pageSize;
		return adminDao.queryAdminWithCriteria(detachedCriteria, firstResult, pageSize);
	}

	@Override
	public boolean deleteAdminByAdminNO(String adminNO) {
		
		return adminDao.deleteAdminByAdminNO(adminNO);
	}

}
